package nl.runnable.solr.util;

import java.util.Map;

import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.search.SolrIndexSearcher;

/**
 * Abstract base class for {@link SolrQueryRequest} wrappers.
 * 
 * @author Laurens Fridael
 * 
 */
@SuppressWarnings("deprecation")
public abstract class SolrQueryRequestWrapper implements SolrQueryRequest {

	private final SolrQueryRequest request;

	protected SolrQueryRequestWrapper(final SolrQueryRequest request) {
		if (request == null) {
			throw new IllegalArgumentException("SolrQueryRequest cannot be null.");
		}
		this.request = request;
	}

	/**
	 * Provides access to the wrapped {@link SolrQueryRequest}.
	 */
	protected SolrQueryRequest getWrappedRequest() {
		return request;
	}

	/* Delegated operations. */

	@Override
	public SolrParams getParams() {
		return request.getParams();
	}

	@Override
	public void setParams(final SolrParams params) {
		request.setParams(params);
	}

	@Override
	public Iterable<ContentStream> getContentStreams() {
		return request.getContentStreams();
	}

	@Override
	public SolrParams getOriginalParams() {
		return request.getOriginalParams();
	}

	@Override
	public Map<Object, Object> getContext() {
		return request.getContext();
	}

	@Override
	public void close() {
		request.close();
	}

	@Override
	public String getParam(final String name) {
		return request.getParam(name);
	}

	@Override
	public String[] getParams(final String name) {
		return request.getParams(name);
	}

	@Override
	public String getQueryString() {
		return request.getQueryString();
	}

	@Override
	public String getQueryType() {
		return request.getQueryType();
	}

	@Override
	public int getStart() {
		return request.getStart();
	}

	@Override
	public int getLimit() {
		return request.getLimit();
	}

	@Override
	public long getStartTime() {
		return request.getStartTime();
	}

	@Override
	public SolrIndexSearcher getSearcher() {
		return request.getSearcher();
	}

	@Override
	public SolrCore getCore() {
		return request.getCore();
	}

	@Override
	public IndexSchema getSchema() {
		return request.getSchema();
	}

	@Override
	public String getParamString() {
		return request.getParamString();
	}
}
